package com.sxjh.controller.cb;

import cn.hutool.extra.cglib.CglibUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxjh.common.BaseController;
import com.sxjh.config.Authorization;
import com.sxjh.common.Result;
import com.sxjh.entity.Materials;
import com.sxjh.entity.param.Finance6ListParam;
import com.sxjh.entity.result.Finance6ListResult;
import com.sxjh.entity.result.MaterialListResult;
import com.sxjh.service.FinanceService;
import com.sxjh.service.MaterialsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/coal")
@Api(tags = "煤")
public class Finance6Controller extends BaseController {

  @Autowired
  private FinanceService financeService;

  @Autowired
  private MaterialsService materialsService;

  @Authorization("cb.coal.list")
  @ApiOperation("列表")
  @GetMapping("/list")
  public Result<List<Finance6ListResult>> fm(@Validated Finance6ListParam param) {
    return ok(financeService.list18(param));
  }

  @ApiOperation("煤物料列表")
  @GetMapping("/materials")
  Result<List<MaterialListResult>> materials() {
    List<Materials> list = materialsService.list(
            new LambdaQueryWrapper<Materials>()
                    .select(Materials::getId, Materials::getName)
                    .eq(Materials::getCategoryId, 9)
                    .isNull(Materials::getDeletedAt));
    List<MaterialListResult> results = CglibUtil.copyList(list, MaterialListResult::new);
    return ok(results);
  }

/*  @Authorization("cb.coal.fm")
  @ApiOperation("肥煤")
  @GetMapping("/fm")
  public Result<List<Finance6ListResult>> fm(@Validated Finance6ListParam param) {
    param.setMaterialId(68);
    return Result.ok(financeService.list18(param));
  }*/

//  @Authorization("cb.coal.dl-jm")
//  @ApiOperation("低硫焦煤")
//  @GetMapping("/dl-jm")
//  public Result<List<Finance6ListResult>> dlJm(@Validated Finance6ListParam param) {
//    param.setMaterialId(69);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.sm")
//  @ApiOperation("瘦煤")
//  @GetMapping("/sm")
//  public Result<List<Finance6ListResult>> sm(@Validated Finance6ListParam param) {
//    param.setMaterialId(70);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.rlm")
//  @ApiOperation("入炉煤")
//  @GetMapping("/rlm")
//  public Result<List<Finance6ListResult>> rlm(@Validated Finance6ListParam param) {
//    param.setMaterialId(71);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.zl-jm")
//  @ApiOperation("中硫焦煤")
//  @GetMapping("/zl-jm")
//  public Result<List<Finance6ListResult>> zlJm(@Validated Finance6ListParam param) {
//    param.setMaterialId(72);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.jm")
//  @ApiOperation("1/3焦煤")
//  @GetMapping("/jm")
//  public Result<List<Finance6ListResult>> jm(@Validated Finance6ListParam param) {
//    param.setMaterialId(63);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.qm")
//  @ApiOperation("气煤")
//  @GetMapping("/qm")
//  public Result<List<Finance6ListResult>> qm(@Validated Finance6ListParam param) {
//    param.setMaterialId(64);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.rzm")
//  @ApiOperation("弱粘煤")
//  @GetMapping("/rzm")
//  public Result<List<Finance6ListResult>> rzm(@Validated Finance6ListParam param) {
//    param.setMaterialId(65);
//    return Result.ok(financeService.list18(param));
//  }
//
//  @Authorization("cb.coal.gl-jm")
//  @ApiOperation("高硫焦煤")
//  @GetMapping("/gl-jm")
//  public Result<List<Finance6ListResult>> glJm(@Validated Finance6ListParam param) {
//    param.setMaterialId(66);
//    return Result.ok(financeService.list18(param));
//  }
}